package com.xczl.demo.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import com.xczl.demo.dao.UserLevelDao;
import com.xczl.demo.domain.UserLevel;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:root-context.xml" })
public class UserLevelDaoTestCase {

	@Autowired
	private UserLevelDao userLevelDao;

	/**
	 * 添加用户级别
	 */
	@Test
	public void insert() {
		UserLevel userLevel = new UserLevel();
		userLevel.setName("VIP会员");
		userLevel.setLevel(5);
		userLevelDao.insertUserLevel(userLevel);
	}

	/**
	 * 根据ID查询用户级别
	 */
	@Test
	public void findById() {
		UserLevel userLevel = userLevelDao.findById(1);
		System.out.println(userLevel.getName());
	}

	/**
	 * 查询所有用户级别
	 */
	@Test
	public void findByAll() {
		List<UserLevel> list = userLevelDao.findAll();
		System.out.println(list.size());
	}

}
